#ifdef _WINDOWS

#include "AccurateTimer.h"
#include "windows.h"
#include <string>


AccurateTimer::AccurateTimer(void)
{
	if(QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER*>(&prevCount)) == 0)
		throw std::string("Cannot run QueryPerformanceCounter...");

	if(QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER*>(&countsPerSec)) == 0)
		throw std::string("Cannot QueryPerformanceFrequency...");
}

AccurateTimer::~AccurateTimer(void)
{
}


double AccurateTimer::reset()
{
	__int64 now;
	
	QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER*>(&now));
	double result = double(now-prevCount)/double(countsPerSec);
	prevCount = now;
	return result;
}

double AccurateTimer::poll()
{
	__int64 now;

	QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER*>(&now));
	return double(now-prevCount)/double(countsPerSec);
}


#endif